package ScoreData;

import static org.junit.Assert.assertTrue;

import org.junit.Before;
import org.junit.Test;

import po.ScoreCellPO;
import po.ScorePO;

public class ScoreDataTest
{
	ScoreDataController sdc;
	ScorePO sp;
	ScoreCellPO scp;
	
	@Before
	public void init() 
	{
		sdc = new ScoreDataController();
		
		scp=new ScoreCellPO();
		scp.score="0";
		scp.studentID="test001";
		scp.lessonID="test001";
		
		sp = new ScorePO();
		sp.list.add(scp);
	}
	
	@Test
	public void insertCell()
	{
		assertTrue(!sdc.insertCell(scp));
	}
	@Test
	public void getOfStudent()
	{
		ScorePO receive = sdc.getOfStudent("test001");
		assertTrue(receive.list.size()==1);
		assertTrue(receive.list.get(0).score.equals("0"));
		receive = sdc.getOfStudent("wrongnumber");
		assertTrue(receive.list.size()==0);
	}
	@Test
	public void set()
	{
		scp.score="1";
		sdc.set(sp);
		assertTrue(sdc.getOfStudent("test001").list.get(0).score.equals("1"));

		scp.score="0";
		sdc.set(sp);
		assertTrue(sdc.getOfStudent("test001").list.get(0).score.equals("0"));
	}
	@Test
	public void getOfTeacher()
	{
		ScorePO receive = sdc.getOfTeacher("test001");
		assertTrue(receive.list.size()==1);
		assertTrue(receive.list.get(0).score.equals("0"));
		
		receive = sdc.getOfTeacher("wrongnumber");
		assertTrue(receive.list.size()==0);
	}
	@Test
	public void delCell()
	{
		assertTrue(sdc.delCell(scp));
		assertTrue(sdc.getOfStudent("test001").list.size()==0);
		assertTrue(sdc.insertCell(scp));
		assertTrue(sdc.getOfStudent("test001").list.size()==1);
	}
}
